home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Virtual User / Virtual User Current Release / Examples / Example Scripts / CloseAllWindows.vu < prev    next >
Encoding:
Text File  |  1998-06-04  |  2.3 KB  |  74 lines  |  [TEXT/MPS ]

  1. #
  2. #    File:            CloseAllWindows.vu
  3. #
  4. #    Contains:        This script tries to close all windows that are open. A more
  5. #                    intelligent form can also be found in UtilityTasks.vulib
  6. #
  7. #    Written by:        P Nagarajan
  8. #
  9. #    Requirements:    none
  10. #
  11. #    After Effects:    Windows that were previously open will be closed.
  12. #
  13. #    Copyright:    © 1989-1992 by Apple Computer, Inc., all rights reserved.
  14. #
  15. #    Change History (most recent first):
  16. #
  17. #                 8/12/92    DGG            Added check for dialogs with "Cancel" button
  18. #                                        but no "OK" button.
  19. #                  8/4/92    DGG            "script" form added to main body
  20. #         <7>     6/18/92    DGG            Added check for "save/don't save" dialog
  21. #         <6>     9/12/91    Rick        Removed Store/Retrieve resources
  22. #        9/9/91                Rick        Add check for 7.0 Finder Desktop window
  23. #        4/3/89                naga        creation 
  24. #
  25. #    To Do:
  26. #
  27.  
  28. (************************************************************************************
  29. * Task CheckForDialog()
  30. *    This will attempt to handle "are you sure" dialogs that may be encountered
  31. *    when closing document windows.
  32. ************************************************************************************)
  33. task CheckForDialog()
  34. begin
  35.     if (match [window o:1 s:dialog])
  36.     begin
  37.         match [staticText t:?theText w:[window o:1]];
  38.         if ((theText ~= /Save≈/) or (theText ~= /Do you want to save≈/))
  39.             if (match [button t:"No"])
  40.                 select [button t:"No"];
  41.             else if (match [button t:/Don≈/])
  42.                 select [button t:/Don≈/];
  43.     end;
  44. end;
  45.  
  46. (************************************************************************************
  47. * Main Body
  48. *    This script will count all the windows present and try to close them.
  49. ************************************************************************************)
  50. script CloseAllWindowsMain()
  51. begin
  52.     allWindows := collect [window];
  53.     totalWindows := card allWindows;
  54.     for i:= 1 to totalWindows do
  55.     begin
  56.         match [window s:?topWindowStyle o:1];
  57.         if (topWindowStyle = dialog)
  58.         begin
  59.             if match [button t:'OK' w:[window o:1]]!
  60.                 select [button t:'OK' w:[window o:1]]!;
  61.             else if match [button t:'Cancel' w:[window o:1]]!
  62.                 select [button t:'Cancel' w:[window o:1]]!;
  63.         end;
  64.         else if not (                                      # skip 7.0 Finder desktop window
  65.                     match[system v:/7.≈/]!                # system 7    ?
  66.                     and match[application t:"Finder"]!    # finder ?
  67.                     and match[window t:"Desktop" o:1]!     # Desktop window ?
  68.                 )
  69.         begin
  70.             close [window o:1];
  71.             CheckForDialog();
  72.         end;
  73.     end; 
  74. end;